package co.edu.usbcali.sgi.modelo.dto;

import co.edu.usbcali.sgi.modelo.Vehiculo;
import co.edu.usbcali.sgi.presentation.backEndBeans.VehiculoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class VehiculoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String vehColor;
    private String estCod_Estado;
    private String marCod_Marca;
    private String perCedula_Persona;
    private String tpvCod_TipoVehiculo;
    private String vehCod;
    private Date vehModelo;
    private boolean rowSelected = false;
    private VehiculoView vehiculoView;
    private Vehiculo vehiculo;

    public Vehiculo getVehiculo() {
        return vehiculo;
    }

    public String listener_update(ActionEvent e) {
        try {
            vehiculoView.action_modifyWitDTO(((vehCod == null) ||
                vehCod.equals("")) ? null : new String(vehCod),
                ((vehColor == null) || vehColor.equals("")) ? null
                                                            : new String(
                    vehColor),
                ((vehModelo == null) || vehModelo.equals("")) ? null : vehModelo,
                ((estCod_Estado == null) || estCod_Estado.equals("")) ? null
                                                                      : new String(
                    estCod_Estado),
                ((marCod_Marca == null) || marCod_Marca.equals("")) ? null
                                                                    : new String(
                    marCod_Marca),
                ((perCedula_Persona == null) || perCedula_Persona.equals(""))
                ? null : new String(perCedula_Persona),
                ((tpvCod_TipoVehiculo == null) ||
                tpvCod_TipoVehiculo.equals("")) ? null
                                                : new String(
                    tpvCod_TipoVehiculo));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        vehCod = vehiculo.getVehCod().toString();
        vehColor = (vehiculo.getVehColor() != null)
            ? vehiculo.getVehColor().toString() : null;
        vehModelo = vehiculo.getVehModelo();
        estCod_Estado = (vehiculo.getEstado().getEstCod() != null)
            ? vehiculo.getEstado().getEstCod().toString() : null;
        marCod_Marca = (vehiculo.getMarca().getMarCod() != null)
            ? vehiculo.getMarca().getMarCod().toString() : null;
        perCedula_Persona = (vehiculo.getPersona().getPerCedula() != null)
            ? vehiculo.getPersona().getPerCedula().toString() : null;
        tpvCod_TipoVehiculo = (vehiculo.getTipoVehiculo().getTpvCod() != null)
            ? vehiculo.getTipoVehiculo().getTpvCod().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        vehCod = vehiculo.getVehCod().toString();
        vehColor = (vehiculo.getVehColor() != null)
            ? vehiculo.getVehColor().toString() : null;
        vehModelo = vehiculo.getVehModelo();
        estCod_Estado = (vehiculo.getEstado().getEstCod() != null)
            ? vehiculo.getEstado().getEstCod().toString() : null;
        marCod_Marca = (vehiculo.getMarca().getMarCod() != null)
            ? vehiculo.getMarca().getMarCod().toString() : null;
        perCedula_Persona = (vehiculo.getPersona().getPerCedula() != null)
            ? vehiculo.getPersona().getPerCedula().toString() : null;
        tpvCod_TipoVehiculo = (vehiculo.getTipoVehiculo().getTpvCod() != null)
            ? vehiculo.getTipoVehiculo().getTpvCod().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setVehiculo(Vehiculo vehiculo) {
        this.vehiculo = vehiculo;
    }

    public VehiculoView getVehiculoView() {
        return vehiculoView;
    }

    public void setVehiculoView(VehiculoView vehiculoView) {
        this.vehiculoView = vehiculoView;
    }

    public String getVehColor() {
        return vehColor;
    }

    public void setVehColor(String vehColor) {
        this.vehColor = vehColor;
    }

    public String getEstCod_Estado() {
        return estCod_Estado;
    }

    public void setEstCod_Estado(String estCod_Estado) {
        this.estCod_Estado = estCod_Estado;
    }

    public String getMarCod_Marca() {
        return marCod_Marca;
    }

    public void setMarCod_Marca(String marCod_Marca) {
        this.marCod_Marca = marCod_Marca;
    }

    public String getPerCedula_Persona() {
        return perCedula_Persona;
    }

    public void setPerCedula_Persona(String perCedula_Persona) {
        this.perCedula_Persona = perCedula_Persona;
    }

    public String getTpvCod_TipoVehiculo() {
        return tpvCod_TipoVehiculo;
    }

    public void setTpvCod_TipoVehiculo(String tpvCod_TipoVehiculo) {
        this.tpvCod_TipoVehiculo = tpvCod_TipoVehiculo;
    }

    public Date getVehModelo() {
        return vehModelo;
    }

    public void setVehModelo(Date vehModelo) {
        this.vehModelo = vehModelo;
    }

    public String getVehCod() {
        return vehCod;
    }

    public void setVehCod(String vehCod) {
        this.vehCod = vehCod;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
